// ！！！通用配置！！！
var storage = storages.create("autotouchShijieXy");

var deviceWidth = device.width > device.height ? device.width : device.height;
var deviceHeight = device.height > device.width ? device.width : device.height;
log('分辨率：', deviceWidth, deviceHeight)
var gamePackageName = "com.qqgame.mic";
var picJizhun = deviceHeight / 1080;
var picJizhunHeight = deviceHeight / 1080;
var yanchi = 500; // 点击后停顿
var yanchi1 = 1000; // 点击前停顿
var yanchi2 = 2000; // 点击后停顿
var yanchi3 = 3000; // 点击后停顿
var yanchi5 = 5000; // 点击后停顿
log('分辨率基准：', picJizhun)
function myLogFunc(params) {
    log(params)
}
xiaodituPosit = storage.get("xiaodituPosit", { x: 0, y: 0 }); // 小地图起始位置


//  应用内操作i
sleep(1000)
picJizhun = 1;


if (deviceHeight == 720) {
    picJizhun = 0.666666666666667;
}
picJizhunHeight = picJizhun

log('分辨率基准：', picJizhun)

app.launchPackage(gamePackageName);
sleep(1000)
//申请截屏权限
if (!requestScreenCapture(true)) {
    toastLog("请求截图失败");
    exit()
}
sleep(2000)

// 前往指定坐标 483就是16 进阶2.82 需要算法支持各种分辨率
function goXyFunc(x, y) {
    myLogFunc('前往坐标点', x, y)
    x = Number(x)
    y = Number(y)
    let zhia = parseInt(x / 50) + 1;
    let jiaozheng = 3;
    if (x < 127) {
        jiaozheng = 2
    //     zhia = zhia - 1;
    }
    let xx = (xiaodituPosit.x + jiaozheng) + ((x + zhia) * (2.756*picJizhun))
    let yy = xiaodituPosit.y + (y * (2.4*picJizhunHeight))
    sleep(yanchi1)
    log('采集点位置：', xx, yy)
    click(xx, yy)
    sleep(yanchi2)
}

// 查看世界地图
function seeShijieditu() {
    let thisImgs = images.read("./res/世界地图按钮.png");
    thisImgs = images.scale(thisImgs, picJizhun, picJizhunHeight)
    let p = findImage(captureScreen(), thisImgs);
    thisImgs.recycle();
    if (p) {
        myLogFunc('打开世界地图')
        sleep(yanchi)
        click(p.x, p.y)
        sleep(yanchi2)

        // 如果是第一次则配置地图 700*600
        if (xiaodituPosit.x == 0) {
            myLogFunc('第一次配置小地图参数')
            sleep(yanchi2)
            let thisImgs1 = images.read("./res/小地图.png");
            thisImgs1 = images.scale(thisImgs1, picJizhun, picJizhunHeight)
            let p1 = findImage(captureScreen(), thisImgs1, { threshold: 0.9 });
            thisImgs1.recycle();
            if (p1) {
                // 以后小地图把p1点当作坐标 0,0
                log(p1)
                let newObj = { x: p1.x, y: p1.y };
                storage.put("xiaodituPosit", newObj);
                xiaodituPosit = storage.get("xiaodituPosit", { x: 0, y: 0 });
                // 700*600 成上基准值
            } else {
                toastLog("小地图信息异常")
                exit()
            }
        }
    } else {
        myLogFunc('打开地图失败')
        sleep(yanchi)
        back()
        sleep(yanchi1)
        seeShijieditu()
    }
}


log("开始")
// sleep(1000)

log('重启')
let thisImgs = images.read("./res/hx_gongbinger.png");
thisImgs = images.scale(thisImgs, picJizhun, picJizhunHeight)
// let p = findImage(captureScreen(), thisImgs, { threshold: 0.86 });
let result = images.matchTemplate(captureScreen(), thisImgs, { threshold: 0.87, max: 2 });
    
thisImgs.recycle();
log(result)
 log('重启1')








function dixitzFunc() {
    // 请求服务
    var req = http.postJson("http://123.60.43.199:8866/main/v1/auto/EmailNotifier", {
        activationCode: storage.get("jihuoma", ""),
        aap: "yxsXysj",
        deviceWidth: device.width,
        deviceHeight: device.height,
        brand: device.brand,
        versionCode: 200,
        release: device.release,
        sdkInt: device.sdkInt,
        androidId: device.getAndroidId(),
        fingerprint: device.fingerprint,
        startTime: new Date().getTime(),
        email: storage.get("userrEmail", "")
    });
    var rJson = req.body.json();
    if (rJson.code != 200) {
        let message = rJson.message ? rJson.message : "服务异常请联系客服！";
        toastLog(message)
        myLogFunc(message)
        sleep(1000)
    } else {
        myLogFunc("已发送邮件通知！")
    }
}

// 采集队列1
function caijiduilieFunc(bloo) {
    log('截取区域')
    let clip = images.clip(captureScreen(), youshangDuilie.x, youshangDuilie.y, youshangDuilie.w, youshangDuilie.h);
    myLogFunc('读取队列')
    log('截图')
    // images.save(clip, "/sdcard/daoyi1.jpg", "jpg", 80);
    log('截图完成')
    let result = paddle.ocrText(clip);
    log('识别完成')
    clip.recycle();
    log('释放截图')
    result = JSON.stringify(result);
    
    log(result)
}



// // 165.61
// var youshangList = [{"x":170,"y":64},{"x":160,"y":64},{"x":160,"y":56},{"x":170,"y":56},{"x":180,"y":56},{"x":180,"y":64},{"x":180,"y":72},{"x":170,"y":72},{"x":160,"y":72},{"x":150,"y":64},{"x":150,"y":56},{"x":150,"y":48},{"x":160,"y":48},{"x":170,"y":48},{"x":180,"y":48},{"x":190,"y":48},{"x":190,"y":56},{"x":190,"y":64},{"x":190,"y":72},{"x":180,"y":80},{"x":170,"y":80},{"x":160,"y":80},{"x":150,"y":80},{"x":150,"y":72},{"x":140,"y":64},{"x":140,"y":56},{"x":140,"y":48},{"x":140,"y":40},{"x":150,"y":40},{"x":160,"y":40},{"x":170,"y":40},{"x":180,"y":40},{"x":190,"y":40},{"x":200,"y":40},{"x":200,"y":48},{"x":200,"y":56},{"x":200,"y":64},{"x":170,"y":88},{"x":160,"y":88},{"x":150,"y":88},{"x":140,"y":88},{"x":140,"y":80},{"x":140,"y":72},{"x":130,"y":64},{"x":130,"y":56},{"x":130,"y":48},{"x":130,"y":40},{"x":130,"y":32},{"x":140,"y":32},{"x":150,"y":32},{"x":160,"y":32},{"x":170,"y":32},{"x":180,"y":32},{"x":190,"y":32},{"x":200,"y":32},{"x":210,"y":40},{"x":210,"y":48},{"x":210,"y":56},{"x":160,"y":96},{"x":150,"y":96},{"x":140,"y":96},{"x":130,"y":96},{"x":130,"y":88},{"x":130,"y":80},{"x":130,"y":72},{"x":130,"y":24},{"x":140,"y":24},{"x":150,"y":24},{"x":160,"y":24},{"x":170,"y":24},{"x":180,"y":24},{"x":190,"y":24},{"x":150,"y":104},{"x":140,"y":104},{"x":130,"y":104},{"x":140,"y":112},{"x":130,"y":112}]
// // // 188.124
// let lmNontinue = 14;
// for (let index = 0; index < youshangList.length; index++) {
//     if (index < lmNontinue) {
//         continue;
//     }
//     let element = youshangList[index];
//     log(element, index)
//     sleep(yanchi)
//     seeShijieditu()
//     sleep(yanchi1)
//     goXyFunc(element.x, element.y)
//     sleep(yanchi3)
// }


// var cunliangWeizhi = storage.get("cunliangWeizhi", { x: 0, y: 0, w: 260, h: 45 }); // 存量起始位置
// var youshangDuilie = { x:deviceWidth - (880*picJizhun), y:(159*picJizhun), w:(880*picJizhun), h: 80 }

// log('截取区域')
//     let clip = images.clip(captureScreen(), youshangDuilie.x, youshangDuilie.y, youshangDuilie.w, youshangDuilie.h);
//     myLogFunc('读取队列')
//     log('截图')
//     // images.save(clip, "/sdcard/daoyi1.jpg", "jpg", 80);
//     log('截图完成')
//     let result = paddle.ocr(clip);
//     log('识别完成')
//     clip.recycle();
//     log('释放截图')
//     log('result', JSON.stringify(result))

//     let myx = deviceWidth - youshangDuilie.w;
//     let myy = youshangDuilie.y;
//     for (let index = 0; index < result.length; index++) {
//         let element = result[index];
//         log(element.text)
//         log(element.bounds)
//         let jina = element.text.match(/集中/g)
//         let x = myx + element.bounds.centerX();
//         let y = myy + element.bounds.centerY();
//         if (jina) {
//             click(x,y)
//             sleep(yanchi3)

//             let thisImgs = images.read("./res/ziyuancaiji.png");
//             thisImgs = images.scale(thisImgs, picJizhun, picJizhunHeight)
//             let resultZy = images.matchTemplate(captureScreen(), thisImgs, { region: [(deviceWidth / 2 - 75), (deviceHeight / 2 - 50), 150, 100], threshold: 0.7, max: 3 });
//             log('resultZy', JSON.stringify(resultZy))
//             thisImgs.recycle();
//             if (resultZy.matches.length) {
//                 if (resultZy.matches.length == 1) {
//                     let p = resultZy.matches[0].point;
//                     click(p.x, p.y)
//                 } else {
//                     myLogFunc('区域多个采集点')
//                     let points = resultZy.sortBy("left-right").points
//                     let lastTimeXy = { x: 0, y: 0 }
//                     for (let index = 0; index < points.length; index++) {
//                         let match = points[index];
//                         log('资源', index, match)
//                         let juli = Math.abs(lastTimeXy.x - match.x)
//                         let juliY = Math.abs(lastTimeXy.y - match.y)
//                         if (juli < 100 && juliY < 5) {
//                             myLogFunc('跳过同一个矿')
//                             continue;
//                         }
//                         sleep(yanchi)
//                         click(match.x, match.y)
//                         // click(deviceWidth / 2, deviceHeight / 2)
//                         lastTimeXy.x = match.x;
//                         lastTimeXy.y = match.y;
        
//                         sleep(yanchi2)

//                         // if (cunliangWeizhi.x != 0) {
//                             log('存量位置', cunliangWeizhi)
//                             let clip = images.clip(captureScreen(), cunliangWeizhi.x, cunliangWeizhi.y, cunliangWeizhi.w, cunliangWeizhi.h);
//                             let result = paddle.ocrText(clip);
//                             log(result)
//                             // 识别容错
//                             if (result.length) {
//                                 result = result[0]
//                             }else{
//                                 log('读取存量异常')
//                                 // return false;
//                             }
//                             log(result)
//                             result = result.substring(2, result.length);
//                             log(result)
//                             if (result) {
//                                 if (result.includes("万")) {
//                                     log("万万");
//                                 } else {
//                                     if (Number(result) < 99 ) {
//                                         myLogFunc('资源存量不足')
                                        
//                                         let thisImgsCh = images.read("./res/撤回.png");
//                                         thisImgsCh = images.scale(thisImgsCh, picJizhun, picJizhunHeight);
//                                         let pCh = findImage(captureScreen(), thisImgsCh);
//                                         thisImgsCh.recycle();
//                                         if (pCh) {
//                                             click(pCh.x, pCh.y)
//                                             sleep(yanchi2)

//                                             let thisImgsQr = images.read("./res/撤回确认.png");
//                                             thisImgsQr = images.scale(thisImgsQr, picJizhun, picJizhunHeight);
//                                             let pQr = findImage(captureScreen(), thisImgsQr);
//                                             thisImgsQr.recycle();
//                                             if (pQr) {
//                                                 click(pQr.x, pQr.y)
//                                             }
//                                         }

//                                         // return false;
//                                     }
//                                     log("不是过万资源");
//                                 }
//                             } else {
//                                 myLogFunc('存量信息有误')
//                             }
//                         // }
//                     }
//                 }
//             }else{
//                 log("啥也没有")
//             }


            
//         }
        
//     }




// var cunliangWeizhi = storage.get("cunliangWeizhi", { x: 0, y: 0, w: 250, h: 45 }); // 存量起始位置

// let thisImgs = images.read("./res/存量.png");
//                 thisImgs = images.scale(thisImgs, picJizhun, picJizhunHeight);
//                 let cunliangP = findImage(captureScreen(), thisImgs, { region: [0, 0, deviceWidth, (deviceHeight / 2)], threshold: 0.85 });
//                 thisImgs.recycle();
//                 if (cunliangP) {
//                     log(cunliangP.x, cunliangP.y)
//                     let cunliangquyu = { x: cunliangP.x, y: cunliangP.y, w: parseInt(250 * picJizhun), h: parseInt(65 * picJizhunHeight) }
//                     cunliangWeizhi = cunliangquyu;
//                     log('cunliangquyu',cunliangquyu)
//                     let clip = images.clip(captureScreen(), cunliangquyu.x, cunliangquyu.y, cunliangquyu.w, cunliangquyu.h);
//                     let result = paddle.ocrText(clip);
//                     log(result)
//                     // 识别容错
//                     if (result.length) {
//                         result = result[0]
//                     }else{
//                         log('读取存量异常')
//                     }
//                     myLogFunc(result)


//                     result = result.substring(2, result.length);
//                     log(result)
//                     if (result.includes("万")) {
//                         log("万万");
//                     } else {
//                         if (Number(result) < Number(storage.get("cunliangNum", "19999"))) {
//                             myLogFunc('资源存量不足1')
//                             log(result,storage.get("cunliangNum", "19999"))
//                             back();
//                             sleep(yanchi)
//                         }
//                         log("不是过万资源");
//                     }
//                 }

// let thisImgs = images.read("./res/一级野.png");
// thisImgs = images.scale(thisImgs, picJizhun, picJizhunHeight);
// let result = images.matchTemplate(captureScreen(), thisImgs, { threshold: 0.85, max: 10 });
// thisImgs.recycle();
// log(cunliangWeizhi)

// var ziyuanZuobianWeizhi = storage.get("ziyuanZuobianWeizhi", { x: 0, y: 0, w: 300, h: 65 }); // 资源信息坐标 
// var cunliangquyu = { x: 1306, y: 312, w: 250, h: 65 }
// let clip = images.clip(captureScreen(), ziyuanZuobianWeizhi.x, ziyuanZuobianWeizhi.y, ziyuanZuobianWeizhi.w, 65);
// let clip = images.clip(captureScreen(), cunliangquyu.x, cunliangquyu.y, cunliangquyu.w, cunliangquyu.h);


// let clip = images.clip(captureScreen(), deviceWidth - 1000, 161, 1000, 80);
//     myLogFunc('读取队列')
//     log('截图')
//     images.save(clip, "/sdcard/daoyi5.jpg", "jpg", 80);
//     log('截图完成')
//     let result = paddle.ocrText(clip);
//     log(result)

// let thisImgs1 = images.read("./res/小主城.png");
//         thisImgs1 = images.scale(thisImgs1, picJizhun, picJizhunHeight)
//         let p1 = findImage(captureScreen(), thisImgs1, { region: [0, (deviceHeight / 2), deviceWidth, (deviceHeight / 2)], threshold: 0.8 });
//         thisImgs1.recycle();
//         if (p1) {
//             log(p1)
//             // let newObj = { x: p1.x, y: p1.y };
//             // storage.put("shangciweizhi", newObj);
//             // shangciweizhi = storage.get("shangciweizhi", { x: 0, y: 0 });
//         }

// log(storage.get("shangciweizhi", { x: 0, y: 0 }))


// let p3 = true;
// while(p3){
//     log(33333)
//     sleep(1000)
//     p3 = null
// }


// var ziyuanZuobianWeizhi = { x: 458, y: 582, w: 300, h: 90 }


// // 智能运行循环定时
// function formatGameTime(params) {
//     params = params.trim()

//     if (!params.includes(':')) {
//         return 0;
//     }
//     params = params.split(":");
//     if (params.length != 3) {
//         return 0;
//     }
    
//     log(Number(params[0]))
//     log(Number(params[1]))
//     log(Number(params[2]))

//     let newTimeSt = (Number(params[0])*60*60 + Number(params[1])*60 + Number(params[2]))*1000;
//     log(newTimeSt)
//     return newTimeSt;
// }


// log(paddle)

// let resultEnd = gmlkit.ocr(captureScreen(), "zh");
//             log(resultEnd)
//  sleep(1111)
// log(111)
// let bb = paddle.ocr(captureScreen())
// log(222)
// log(bb)
// paddle.ocrText(captureScreen())


// myLogFunc('第一次配置存量信息')
// sleep(2000)
// myLogFunc('截图')
// let thisImgs = images.read("./res/存量.png");
// thisImgs = images.scale(thisImgs, picJizhun, picJizhunHeight);
// let cunliangP = findImage(captureScreen(), thisImgs, { region: [0, 0, deviceWidth, (deviceHeight / 2)], threshold: 0.85 });
// thisImgs.recycle();
// if (cunliangP) {
//     log(cunliangP.x, cunliangP.y)
//     let cunliangquyu = { x: cunliangP.x, y: cunliangP.y, w: parseInt(250 * picJizhun), h: parseInt(50 * picJizhunHeight) }
//     // cunliangWeizhi = cunliangquyu;
//     log(cunliangquyu.w, cunliangquyu.h)
//     let clip = images.clip(captureScreen(), cunliangquyu.x, cunliangquyu.y, cunliangquyu.w, cunliangquyu.h);


//     let result = paddle.ocrText(clip);
//     log(result)
//     // 识别容错
//     if (result) {
//         result = result[0]
//     }
//     log(result)

//     // let result = gmlkit.ocr(clip, "zh");
//     clip.recycle();
//     // result = result.text;
//     // log(result)
//     result = result.substring(2, result.length);
//     log(result)
//     if (result.includes("万")) {
//         log("万万");
//     } else {
//         if (result < storage.get("cunliangNum", "19999")) {
//             myLogFunc('资源存量不足1')
//             log(storage.get("cunliangNum", "19999"))
//             back();
//             sleep(yanchi)
//             // return false;
//         }
//         log("不是过万资源");
//     }

//     // storage.put("cunliangWeizhi", cunliangWeizhi);
// }else{
//     log('读取图片失败')
// }


// let myx = deviceWidth- 1000;
// let myy = 160;
// let clip = images.clip(captureScreen(), deviceWidth - 1000, 160, 1000, 80);
// let result = paddle.ocr(clip);
// clip.recycle();
// log(result)
// result.forEach((element, index) => {
//     log(index ,element.text)
//     // let jina = element.text.match(/进|连|讲/g)
//     // log(jina)
//     // if (jina) {
//     //     let x = myx + element.bounds.centerX();
//     //     let y = myy + element.bounds.centerY();
//     //     log(x,y)
//     //     click(x,y)
//     //     sleep(1000)
//     //     back()
//     //     sleep(1000)
//     // }
// });
        // let taofaNum = result1.match(/进|连|讲/g)
        // if (taofaNum) {
        //     dayeduiwu = taofaNum.length
        //     myLogFunc('存在讨伐队伍' + dayeduiwu)
        // }

// let clip = images.clip(captureScreen(), deviceWidth - 1000, 160, 1000, 80);
//         // let result = gmlkit.ocr(clip, "zh");
//         // log(result)
//         // log(result.text)

//         let result1 = paddle.ocr(clip);
//         log('result1',result1)

//         // let result2 = paddle.ocrText(clip);
//         // result2 = JSON.stringify(result2)
//         // log('result2:'+result2)
//         // // result2 = '["进入过代","进入过作","讨作","采集中","采集中","采集可","00:04:07","00:03:52","00:03：55","00:10:43","00:18:59","00:23:0","N"]'
//         // let guoNum = result2.match(/过|讨/g)
//         // log(guoNum) 


//         clip.recycle();

 


// log(1)
// let cap = captureScreen()
// log(2)
// let clip = images.clip(cap, ziyuanZuobianWeizhi.x, ziyuanZuobianWeizhi.y, ziyuanZuobianWeizhi.w, ziyuanZuobianWeizhi.h);
// log(3)
// let resultGm = gmlkit.ocr(clip, "en");
// log('resultGm',resultGm)
// log(resultGm.text)
// log(resultGm.text.length)
// log(3.5)


// log('设置-智能运行')
//                 let clipRestart = images.clip(captureScreen(), deviceWidth - 1000, 80, 1000, 140);
//                 let paddleOcrRestart = paddle.ocr(clipRestart);
//                 clipRestart.recycle();
//                 log("paddleOcrRestart", paddleOcrRestart)
//                 let restartTime = 0;
//                 for (let index = 0; index < paddleOcrRestart.length; index++) {
//                     let element = paddleOcrRestart[index];
//                     if (element.text.includes(':')) {
//                         log('采集剩余时间:'+element.text)
//                         let shortest = formatGameTime(element.text);
//                         log('index',index)
//                         if (restartTime == 0) {
//                             log('index == 0')
//                             restartTime = shortest;
//                             log('restartTime', restartTime)
//                         }

//                         if (shortest < restartTime) {
//                             log('较短时间:'+element.text)
//                             restartTime = shortest;
//                         }
//                     }
//                 }
//                 let restartTimeFen = parseInt(restartTime/1000/60)
//                 log('最短时间:'+restartTimeFen+'分钟！')
//                 sleep(2500)
//                 // 小于十分钟
//                 let runAgainTime = restartTime + (1000*120)
//                 // if (restartTimeFen > 10) {
//                     log('等待较短采集任务！')
//                     let reloadTimeOut = setTimeout(() => {
//                         // 重新运行
//                         mainFunc()
//                         clearTimeout(reloadTimeOut)
//                     }, runAgainTime );
                // }


// var storage = storages.create("autotouchShijieXy");

// // 默认参数
// var picJizhun = 1;
// var picJizhunHeight = 1;

// var gamePackageName = "com.qqgame.mic";
// var gameActivity = "com.qqgame.mic.YXSMainActivity";






// var ziyuanZuobianWeizhi = storage.get("ziyuanZuobianWeizhi", { x: 0, y: 0, w: 300, h: 60 }); // 资源信息坐标

// function log() {
//     log(arguments)
// }

// // log('@@@@@@@@@@@@@@@@@@@@@@@@@@')

// // var req = http.postJson("http://123.60.43.199:8866/main/v1/auto/testApp", {
// //             activationCode: storage.get("jihuoma", "ILAT2K9EZSQMCLDGB62HMSL5SU1U"),
// //             aap: "yxs",
// //             deviceWidth: deviceWidth,
// //             deviceHeight: deviceHeight,
// //             brand: device.brand,
// //             versionCode: "88",
// //             release: device.release,
// //             sdkInt: device.sdkInt,
// //             androidId: device.getAndroidId(),
// //             fingerprint: device.fingerprint,
// //             // mac: device.getMacAddress(), //雷电5崩溃
// //             // iMEI: device.getIMEI(), // 需要权限 否则报错
// //             startTime: new Date().getTime()
// //         });
// //         var rJson = req.body.json();
// //         if (rJson.code != 200) {
// //             let message = rJson.message ? rJson.message : "服务异常请联系客服！";
// //             toastLog(message)
// //             sleep(1000)
// //             exit()
// //             sleep(2000)
// //         } else {
// //             log("服务成功注册！")
// //         }

// //         sleep(5000)
// //         log('############')

        





//  // 检查无障碍服务是否已经启用，如果没有启用则跳转到无障碍服务启用界面，并等待无障碍服务启动；当无障碍服务启动后脚本会继续运行。
//  auto.waitFor()
//  //截图权限自动化安卓版本高于Android 9
//  if (device.sdkInt > 27) {
//      //等待截屏权限申请并同意
//      threads.start(function () {
//          if (device.brand == "HUAWEI") {
//              packageName('com.android.systemui').text('允许').waitFor();
//              sleep(500)
//              text('允许').click();
//          } else {
//              packageName('com.android.systemui').text('立即开始').waitFor();
//              sleep(500)
//              text('立即开始').click();
//          }
//      });
//  }
//  // 启动游戏
//  var appPackName = currentPackage();
//  log("当前程序：", appPackName)
//  if (appPackName != gamePackageName) {
//      app.launchPackage(gamePackageName);
//      log("游戏启动中，请稍等...")
//      sleep(3000)
//      //申请截屏权限
//      if (!requestScreenCapture(true)) {
//          toastLog("请求截图失败");
//          exit()
//      }
//      appPackName = currentPackage();
//      if (appPackName == gamePackageName) {
//          log("英雄杀已打开，请稍等...")
//      }
//      if (false) {
//          sleep(yanchi5 * 3)
//      } else {
//          sleep(yanchi1)
//      }
//  } else {
//      log("游戏正在运行");
//      //申请截屏权限
//      if (!requestScreenCapture(true)) {
//          toastLog("请求截图失败");
//          exit()
//      }
//  }

// function formatGameTime(params) {
//     if (!params.includes(':')) {
//         return 0;
//     }
//     params = params.split(":");
//     if (params.length != 3) {
//         return 0;
//     }
    
//     log(Number(params[0]))
//     log(Number(params[1]))
//     log(Number(params[2]))

//     let newTimeSt = (Number(params[0])*60*60 + Number(params[1])*60 + Number(params[2]))*1000;
//     log(newTimeSt)
//     return newTimeSt;
// }

//  let clipEnd = images.clip(captureScreen(), deviceWidth - 1000, 80, 1000, 140);
//             let resultEnd = gmlkit.ocr(clipEnd, "zh");
//             log(resultEnd)
//             log(resultEnd.text)

//             let paddleOcrEnd = paddle.ocr(clipEnd);
//             log("paddle.ocr END", paddleOcrEnd)

//             for (let index = 0; index < paddleOcrEnd.length; index++) {
//                 let element = paddleOcrEnd[index];
//                 if (element.text.includes(':')) {
//                     log('@@@', element.text)
//                     formatGameTime(element.text)
//                 }
//             }


// //  images.matchTemplate
// //  let thisImgs1 = images.read("./res/坐标背景图.png");
// //                         thisImgs1 = images.scale(thisImgs1, picJizhun, picJizhunHeight)
// //                         let p1 = findImage(captureScreen(), thisImgs1, { region: [0, 0, (deviceWidth / 2), deviceHeight], threshold: 0.7 });
// //                         thisImgs1.recycle();
// //                         log("p1", p1)

// // sleep(500)
// //  let clip = images.clip(captureScreen(), p1.x+50, p1.y, ziyuanZuobianWeizhi.w, ziyuanZuobianWeizhi.h);
// //                     log(3)
// //                     images.save(clip, "/sdcard/clipasd.png") // 坐标截取
// //                     let res = paddle.ocr(clip);
// //                     log("坐标截取", res)


//                 //     let result = gmlkit.ocr(clip, "zh");
//                 // result = result.text;
//                 // log(result)
//                 // log(result[0].text)


// //  sleep(yanchi2)
// //  log('第一次配置小地图参数')
// //         sleep(yanchi2)
// //         let thisImgs1 = images.read("./res/小地图.png");
// //         let thisImgs2 = images.read("./res/777.png");
// //         thisImgs1 = images.scale(thisImgs1, picJizhun, picJizhunHeight)


// //         let p1 = findImage(captureScreen(), thisImgs1, { threshold: 0.8 });
// //         let result = images.matchTemplate(captureScreen(), thisImgs1, { threshold: 0.9, max: 2 });
// //         log("result",result)
// //         thisImgs1.recycle();
// //         if (p1) {
// //             // 以后小地图把p1点当作坐标 0,0
// //             log(p1)
// //             let newObj = { x: p1.x, y: p1.y };
// //             storage.put("xiaodituPosit", { x: 0, y: 0 });
// //             // xiaodituPosit = storage.get("xiaodituPosit", { x: 0, y: 0 });
// //             // 700*600 成上基准值
// //             toastLog('配置完成请查看日志')
// //         } else {
// //             toastLog("小地图信息异常")
// //             exit()
// //         }



// var youshangList = [{ "x": 130, "y": 24 }, { "x": 130, "y": 32 }, { "x": 130, "y": 40 }, { "x": 130, "y": 48 }, { "x": 130, "y": 56 }, { "x": 130, "y": 64 }, { "x": 130, "y": 72 }, { "x": 130, "y": 80 }, { "x": 130, "y": 88 }, { "x": 130, "y": 96 }, { "x": 130, "y": 104 }, { "x": 130, "y": 112 }, { "x": 130, "y": 120 }, { "x": 140, "y": 24 }, { "x": 140, "y": 32 }, { "x": 140, "y": 40 }, { "x": 140, "y": 48 }, { "x": 140, "y": 56 }, { "x": 140, "y": 64 }, { "x": 140, "y": 72 }, { "x": 140, "y": 80 }, { "x": 140, "y": 88 }, { "x": 140, "y": 96 }, { "x": 140, "y": 104 }, { "x": 140, "y": 112 }, { "x": 150, "y": 24 }, { "x": 150, "y": 32 }, { "x": 150, "y": 40 }, { "x": 150, "y": 48 }, { "x": 150, "y": 56 }, { "x": 150, "y": 64 }, { "x": 150, "y": 72 }, { "x": 150, "y": 80 }, { "x": 150, "y": 88 }, { "x": 150, "y": 96 }, { "x": 150, "y": 104 }, { "x": 160, "y": 24 }, { "x": 160, "y": 32 }, { "x": 160, "y": 40 }, { "x": 160, "y": 48 }, { "x": 160, "y": 56 }, { "x": 160, "y": 64 }, { "x": 160, "y": 72 }, { "x": 160, "y": 80 }, { "x": 160, "y": 88 }, { "x": 160, "y": 96 }, { "x": 170, "y": 24 }, { "x": 170, "y": 32 }, { "x": 170, "y": 40 }, { "x": 170, "y": 48 }, { "x": 170, "y": 56 }, { "x": 170, "y": 64 }, { "x": 170, "y": 72 }, { "x": 170, "y": 80 }, { "x": 170, "y": 88 }, { "x": 180, "y": 24 }, { "x": 180, "y": 32 }, { "x": 180, "y": 40 }, { "x": 180, "y": 48 }, { "x": 180, "y": 56 }, { "x": 180, "y": 64 }, { "x": 180, "y": 72 }, { "x": 180, "y": 80 }, { "x": 190, "y": 24 }, { "x": 190, "y": 32 }, { "x": 190, "y": 40 }, { "x": 190, "y": 48 }, { "x": 190, "y": 56 }, { "x": 190, "y": 64 }, { "x": 190, "y": 72 }, { "x": 200, "y": 24 }, { "x": 200, "y": 32 }, { "x": 200, "y": 40 }, { "x": 200, "y": 48 }, { "x": 200, "y": 56 }, { "x": 200, "y": 64 }, { "x": 210, "y": 24 }, { "x": 210, "y": 32 }, { "x": 210, "y": 40 }, { "x": 210, "y": 48 }, { "x": 210, "y": 56 }, { "x": 220, "y": 24 }, { "x": 220, "y": 32 }, { "x": 220, "y": 40 }, { "x": 220, "y": 48 }];
// var youzhongList = [{ "x": 140, "y": 120 }, { "x": 140, "y": 128 }, { "x": 150, "y": 112 }, { "x": 150, "y": 120 }, { "x": 150, "y": 128 }, { "x": 150, "y": 136 }, { "x": 160, "y": 104 }, { "x": 160, "y": 112 }, { "x": 160, "y": 120 }, { "x": 160, "y": 128 }, { "x": 160, "y": 136 }, { "x": 160, "y": 144 }, { "x": 170, "y": 96 }, { "x": 170, "y": 104 }, { "x": 170, "y": 112 }, { "x": 170, "y": 120 }, { "x": 170, "y": 128 }, { "x": 170, "y": 136 }, { "x": 170, "y": 144 }, { "x": 180, "y": 88 }, { "x": 180, "y": 96 }, { "x": 180, "y": 104 }, { "x": 180, "y": 112 }, { "x": 180, "y": 120 }, { "x": 180, "y": 128 }, { "x": 180, "y": 136 }, { "x": 180, "y": 144 }, { "x": 180, "y": 152 }, { "x": 190, "y": 80 }, { "x": 190, "y": 88 }, { "x": 190, "y": 96 }, { "x": 190, "y": 104 }, { "x": 190, "y": 112 }, { "x": 190, "y": 120 }, { "x": 190, "y": 128 }, { "x": 190, "y": 136 }, { "x": 190, "y": 144 }, { "x": 190, "y": 152 }, { "x": 190, "y": 160 }, { "x": 200, "y": 72 }, { "x": 200, "y": 80 }, { "x": 200, "y": 88 }, { "x": 200, "y": 96 }, { "x": 200, "y": 104 }, { "x": 200, "y": 112 }, { "x": 200, "y": 120 }, { "x": 200, "y": 128 }, { "x": 200, "y": 136 }, { "x": 200, "y": 144 }, { "x": 200, "y": 152 }, { "x": 200, "y": 160 }, { "x": 200, "y": 168 }, { "x": 210, "y": 64 }, { "x": 210, "y": 72 }, { "x": 210, "y": 80 }, { "x": 210, "y": 88 }, { "x": 210, "y": 96 }, { "x": 210, "y": 104 }, { "x": 210, "y": 112 }, { "x": 210, "y": 120 }, { "x": 210, "y": 128 }, { "x": 210, "y": 136 }, { "x": 210, "y": 144 }, { "x": 210, "y": 152 }, { "x": 210, "y": 160 }, { "x": 210, "y": 168 }, { "x": 220, "y": 56 }, { "x": 220, "y": 64 }, { "x": 220, "y": 72 }, { "x": 220, "y": 80 }, { "x": 220, "y": 88 }, { "x": 220, "y": 96 }, { "x": 220, "y": 104 }, { "x": 220, "y": 112 }, { "x": 220, "y": 120 }, { "x": 220, "y": 128 }, { "x": 220, "y": 136 }, { "x": 220, "y": 144 }, { "x": 220, "y": 152 }, { "x": 220, "y": 160 }, { "x": 220, "y": 168 }, { "x": 220, "y": 176 }];
// var youxiaList = [{ "x": 130, "y": 128 }, { "x": 130, "y": 136 }, { "x": 130, "y": 144 }, { "x": 130, "y": 152 }, { "x": 130, "y": 160 }, { "x": 130, "y": 168 }, { "x": 130, "y": 176 }, { "x": 130, "y": 184 }, { "x": 130, "y": 192 }, { "x": 130, "y": 200 }, { "x": 130, "y": 208 }, { "x": 130, "y": 216 }, { "x": 140, "y": 136 }, { "x": 140, "y": 144 }, { "x": 140, "y": 152 }, { "x": 140, "y": 160 }, { "x": 140, "y": 168 }, { "x": 140, "y": 176 }, { "x": 140, "y": 184 }, { "x": 140, "y": 192 }, { "x": 140, "y": 200 }, { "x": 140, "y": 208 }, { "x": 140, "y": 216 }, { "x": 150, "y": 144 }, { "x": 150, "y": 152 }, { "x": 150, "y": 160 }, { "x": 150, "y": 168 }, { "x": 150, "y": 176 }, { "x": 150, "y": 184 }, { "x": 150, "y": 192 }, { "x": 150, "y": 200 }, { "x": 150, "y": 208 }, { "x": 150, "y": 216 }, { "x": 160, "y": 152 }, { "x": 160, "y": 160 }, { "x": 160, "y": 168 }, { "x": 160, "y": 176 }, { "x": 160, "y": 184 }, { "x": 160, "y": 192 }, { "x": 160, "y": 200 }, { "x": 160, "y": 208 }, { "x": 160, "y": 216 }, { "x": 170, "y": 152 }, { "x": 170, "y": 160 }, { "x": 170, "y": 168 }, { "x": 170, "y": 176 }, { "x": 170, "y": 184 }, { "x": 170, "y": 192 }, { "x": 170, "y": 200 }, { "x": 170, "y": 208 }, { "x": 170, "y": 216 }, { "x": 180, "y": 160 }, { "x": 180, "y": 168 }, { "x": 180, "y": 176 }, { "x": 180, "y": 184 }, { "x": 180, "y": 192 }, { "x": 180, "y": 200 }, { "x": 180, "y": 208 }, { "x": 180, "y": 216 }, { "x": 190, "y": 168 }, { "x": 190, "y": 176 }, { "x": 190, "y": 184 }, { "x": 190, "y": 192 }, { "x": 190, "y": 200 }, { "x": 190, "y": 208 }, { "x": 190, "y": 216 }, { "x": 200, "y": 176 }, { "x": 200, "y": 184 }, { "x": 200, "y": 192 }, { "x": 200, "y": 200 }, { "x": 200, "y": 208 }, { "x": 200, "y": 216 }, { "x": 210, "y": 176 }, { "x": 210, "y": 184 }, { "x": 210, "y": 192 }, { "x": 210, "y": 200 }, { "x": 210, "y": 208 }, { "x": 210, "y": 216 }, { "x": 220, "y": 184 }, { "x": 220, "y": 192 }, { "x": 220, "y": 200 }, { "x": 220, "y": 208 }];
// var zuoxiaList = [{ "x": 30, "y": 184 }, { "x": 30, "y": 192 }, { "x": 30, "y": 200 }, { "x": 30, "y": 208 }, { "x": 40, "y": 184 }, { "x": 40, "y": 192 }, { "x": 40, "y": 200 }, { "x": 40, "y": 208 }, { "x": 50, "y": 176 }, { "x": 50, "y": 184 }, { "x": 50, "y": 192 }, { "x": 50, "y": 200 }, { "x": 50, "y": 208 }, { "x": 50, "y": 216 }, { "x": 60, "y": 168 }, { "x": 60, "y": 176 }, { "x": 60, "y": 184 }, { "x": 60, "y": 192 }, { "x": 60, "y": 200 }, { "x": 60, "y": 208 }, { "x": 60, "y": 216 }, { "x": 70, "y": 160 }, { "x": 70, "y": 168 }, { "x": 70, "y": 176 }, { "x": 70, "y": 184 }, { "x": 70, "y": 192 }, { "x": 70, "y": 200 }, { "x": 70, "y": 208 }, { "x": 70, "y": 216 }, { "x": 80, "y": 160 }, { "x": 80, "y": 168 }, { "x": 80, "y": 176 }, { "x": 80, "y": 184 }, { "x": 80, "y": 192 }, { "x": 80, "y": 200 }, { "x": 80, "y": 208 }, { "x": 80, "y": 216 }, { "x": 90, "y": 152 }, { "x": 90, "y": 160 }, { "x": 90, "y": 168 }, { "x": 90, "y": 176 }, { "x": 90, "y": 184 }, { "x": 90, "y": 192 }, { "x": 90, "y": 200 }, { "x": 90, "y": 208 }, { "x": 90, "y": 216 }, { "x": 100, "y": 144 }, { "x": 100, "y": 152 }, { "x": 100, "y": 160 }, { "x": 100, "y": 168 }, { "x": 100, "y": 176 }, { "x": 100, "y": 184 }, { "x": 100, "y": 192 }, { "x": 100, "y": 200 }, { "x": 100, "y": 208 }, { "x": 100, "y": 216 }, { "x": 110, "y": 136 }, { "x": 110, "y": 144 }, { "x": 110, "y": 152 }, { "x": 110, "y": 160 }, { "x": 110, "y": 168 }, { "x": 110, "y": 176 }, { "x": 110, "y": 184 }, { "x": 110, "y": 192 }, { "x": 110, "y": 200 }, { "x": 110, "y": 208 }, { "x": 110, "y": 216 }, { "x": 120, "y": 136 }, { "x": 120, "y": 144 }, { "x": 120, "y": 152 }, { "x": 120, "y": 160 }, { "x": 120, "y": 168 }, { "x": 120, "y": 176 }, { "x": 120, "y": 184 }, { "x": 120, "y": 192 }, { "x": 120, "y": 200 }, { "x": 120, "y": 208 }, { "x": 120, "y": 216 }];


// // 给定的坐标系
// // const coordinates = [{ "x": 30, "y": 24 }, { "x": 40, "y": 24 }, { "x": 40, "y": 32 }, { "x": 50, "y": 24 }, { "x": 50, "y": 32 }, { "x": 50, "y": 40 }, { "x": 50, "y": 48 }, { "x": 60, "y": 24 }, { "x": 60, "y": 32 }, { "x": 60, "y": 40 }, { "x": 60, "y": 48 }, { "x": 60, "y": 56 }, { "x": 70, "y": 24 }, { "x": 70, "y": 32 }, { "x": 70, "y": 40 }, { "x": 70, "y": 48 }, { "x": 70, "y": 56 }, { "x": 70, "y": 64 }, { "x": 80, "y": 24 }, { "x": 80, "y": 32 }, { "x": 80, "y": 40 }, { "x": 80, "y": 48 }, { "x": 80, "y": 56 }, { "x": 80, "y": 64 }, { "x": 80, "y": 72 }, { "x": 90, "y": 24 }, { "x": 90, "y": 32 }, { "x": 90, "y": 40 }, { "x": 90, "y": 48 }, { "x": 90, "y": 56 }, { "x": 90, "y": 64 }, { "x": 90, "y": 72 }, { "x": 90, "y": 80 }, { "x": 90, "y": 88 }, { "x": 100, "y": 24 }, { "x": 100, "y": 32 }, { "x": 100, "y": 40 }, { "x": 100, "y": 48 }, { "x": 100, "y": 56 }, { "x": 100, "y": 64 }, { "x": 100, "y": 72 }, { "x": 100, "y": 80 }, { "x": 100, "y": 88 }, { "x": 100, "y": 96 }, { "x": 110, "y": 24 }, { "x": 110, "y": 32 }, { "x": 110, "y": 40 }, { "x": 110, "y": 48 }, { "x": 110, "y": 56 }, { "x": 110, "y": 64 }, { "x": 110, "y": 72 }, { "x": 110, "y": 80 }, { "x": 110, "y": 88 }, { "x": 110, "y": 96 }, { "x": 110, "y": 104 }, { "x": 120, "y": 24 }, { "x": 120, "y": 32 }, { "x": 120, "y": 40 }, { "x": 120, "y": 48 }, { "x": 120, "y": 56 }, { "x": 120, "y": 64 }, { "x": 120, "y": 72 }, { "x": 120, "y": 80 }, { "x": 120, "y": 88 }, { "x": 120, "y": 96 }, { "x": 120, "y": 104 }, { "x": 120, "y": 112 }];
// var centerX = 156;
// var centerY = 187;

// let coordinates =  youxiaList;

// // 计算每个点到中心点的距离
// function distanceToCenter(coord) {
//     const dx = coord.x - centerX;
//     const dy = coord.y - centerY;
//     return Math.sqrt(dx * dx + dy * dy);
// }

// // 按距离从小到大对坐标进行排序
// coordinates.sort((a, b) => distanceToCenter(a) - distanceToCenter(b));

// console.log(JSON.stringify(coordinates));


// // 计算点与中心点的角度（以x轴正方向为基准，顺时针为正）
// function angleFromCenter(coord) {
//     const dx = coord.x - centerX;
//     const dy = coord.y - centerY;
//     let angle = Math.atan2(dy, dx) * 180 / Math.PI;
//     if (angle < 0) angle += 360; // 确保角度在0到359之间
//     return angle;
// }

// // 按照距离从近到远对坐标进行排序
// coordinates.sort((a, b) => {
//     const distanceA = Math.sqrt((a.x - centerX) ** 2 + (a.y - centerY) ** 2);
//     const distanceB = Math.sqrt((b.x - centerX) ** 2 + (b.y - centerY) ** 2);
//     return distanceA - distanceB;
// });

// // 对于距离相同的点，按照顺时针方向排序
// coordinates.sort((a, b) => {
//     const angleDiff = angleFromCenter(a) - angleFromCenter(b);
//     if (angleDiff !== 0) {
//         return angleDiff;
//     }
//     return 0; // 保持原来的相对顺序
// });

// console.log(coordinates);















// // 中心点坐标
// const centerX = 45;
// const centerY = 30;

// // 计算每个点到中心点的距离的平方（为了减少开方计算）
// function distanceSquared(coord) {
//     const dx = coord.x - centerX;
//     const dy = coord.y - centerY;
//     return dx * dx + dy * dy;
// }

// // 按距离从小到大对坐标进行排序
// coordinates.sort((a, b) => distanceSquared(a) - distanceSquared(b));

// console.log(coordinates);


// // 计算点相对于中心点的角度（以y轴正方向为基准，逆时针为正）
// function angleFromCenter(coord) {
//     const dx = coord.x - 24;
//     const dy = coord.y - 24;
//     return Math.atan2(dy, dx) * (180 / Math.PI);
// }

// // 按角度从小到大对坐标进行排序
// coordinates.sort((a, b) => angleFromCenter(a) - angleFromCenter(b));

// console.log(coordinates);


// // 计算点相对于中心点的角度（以x轴正方向为基准，顺时针为正）
// function angleFromCenter(coord) {
//     const dx = coord.x - centerX;
//     const dy = coord.y - centerY;
//     return Math.atan2(dy, dx) * (180 / Math.PI);
// }

// // 按角度从小到大对坐标进行排序
// coordinates.sort((a, b) => {
//     const angleA = (360 + angleFromCenter(a)) % 360;
//     const angleB = (360 + angleFromCenter(b)) % 360;
//     return angleA - angleB;
// });

// console.log(coordinates);


// // 计算每个点到中心点的距离
// function distanceToCenter(coord) {
//     return Math.sqrt(Math.pow(coord.x - centerX, 2) + Math.pow(coord.y - centerY, 2));
// }

// // 按距离从小到大对坐标进行排序
// coordinates.sort((a, b) => distanceToCenter(a) - distanceToCenter(b));

// log(coordinates);




// // if (!requestScreenCapture(true)) {
// //     toastLog("请求截图失败");
// //     exit()
// // }
// // sleep(5000)
// // var deviceWidth = device.width > device.height ? device.width : device.height;
// // var deviceHeight = device.height > device.width ? device.width : device.height;

// // // let clip = images.clip(captureScreen(), (deviceWidth/2 - 200), 80, 400, 150);

// // let thisImgs = images.read("./res/存量.png");
// // thisImgs = images.scale(thisImgs, picJizhun, picJizhunHeight);
// // let cunliangP = findImage(captureScreen(), thisImgs, { region: [0, 0, deviceWidth, (deviceHeight / 2)], threshold: 0.9 });
// // thisImgs.recycle();
// // if (cunliangP) {
// //     log(cunliangP)
// //     log(cunliangP.x, cunliangP.y)
// //     let cunliangquyu = { x: cunliangP.x, y: cunliangP.y, w: parseInt(250 * picJizhun), h: parseInt(45 * picJizhunHeight) }
// //     log(cunliangquyu.w, cunliangquyu.h)
// //     let clip = images.clip(captureScreen(), cunliangquyu.x, cunliangquyu.y, cunliangquyu.w, cunliangquyu.h);
// //     let result = gmlkit.ocr(clip, "zh");
// //     result = result.text
// //     result = result.substring(2, result.length);

// //     log('@@@', result)
// //     if (result.includes("万")) {
// //         log("万万");
// //     } else {
// //         if (result > storage.get("cunliangNum", "19999")) {

// //         }
// //         log("字符串不包含 'World'");
// //     }

// //     storage.put("cunliangWeizhi", cunliangWeizhi);
// // }










// // // 前台服务状态
// // log('前台服务: ' + $settings.isEnabled('foreground_service'))
// // // 开启前台服务
// // $settings.setEnabled('foreground_service', true);




// // // // 默认参数
// // var picJizhun = 1;
// // var picJizhunHeight = 1;
// // var zuoshang = [{"x":30,"y":24},{"x":40,"y":24},{"x":40,"y":32},{"x":50,"y":24},{"x":50,"y":32},{"x":50,"y":40},{"x":50,"y":48},{"x":60,"y":24},{"x":60,"y":32},{"x":60,"y":40},{"x":60,"y":48},{"x":60,"y":56},{"x":70,"y":24},{"x":70,"y":32},{"x":70,"y":40},{"x":70,"y":48},{"x":70,"y":56},{"x":70,"y":64},{"x":80,"y":24},{"x":80,"y":32},{"x":80,"y":40},{"x":80,"y":48},{"x":80,"y":56},{"x":80,"y":64},{"x":80,"y":72},{"x":90,"y":24},{"x":90,"y":32},{"x":90,"y":40},{"x":90,"y":48},{"x":90,"y":56},{"x":90,"y":64},{"x":90,"y":72},{"x":90,"y":80},{"x":90,"y":88},{"x":100,"y":24},{"x":100,"y":32},{"x":100,"y":40},{"x":100,"y":48},{"x":100,"y":56},{"x":100,"y":64},{"x":100,"y":72},{"x":100,"y":80},{"x":100,"y":88},{"x":100,"y":96},{"x":110,"y":24},{"x":110,"y":32},{"x":110,"y":40},{"x":110,"y":48},{"x":110,"y":56},{"x":110,"y":64},{"x":110,"y":72},{"x":110,"y":80},{"x":110,"y":88},{"x":110,"y":96},{"x":110,"y":104},{"x":120,"y":24},{"x":120,"y":32},{"x":120,"y":40},{"x":120,"y":48},{"x":120,"y":56},{"x":120,"y":64},{"x":120,"y":72},{"x":120,"y":80},{"x":120,"y":88},{"x":120,"y":96},{"x":120,"y":104},{"x":120,"y":112}];
// // var youshang = [{"x":130,"y":24},{"x":130,"y":32},{"x":130,"y":40},{"x":130,"y":48},{"x":130,"y":56},{"x":130,"y":64},{"x":130,"y":72},{"x":130,"y":80},{"x":130,"y":88},{"x":130,"y":96},{"x":130,"y":104},{"x":130,"y":112},{"x":130,"y":120},{"x":140,"y":24},{"x":140,"y":32},{"x":140,"y":40},{"x":140,"y":48},{"x":140,"y":56},{"x":140,"y":64},{"x":140,"y":72},{"x":140,"y":80},{"x":140,"y":88},{"x":140,"y":96},{"x":140,"y":104},{"x":140,"y":112},{"x":150,"y":24},{"x":150,"y":32},{"x":150,"y":40},{"x":150,"y":48},{"x":150,"y":56},{"x":150,"y":64},{"x":150,"y":72},{"x":150,"y":80},{"x":150,"y":88},{"x":150,"y":96},{"x":150,"y":104},{"x":160,"y":24},{"x":160,"y":32},{"x":160,"y":40},{"x":160,"y":48},{"x":160,"y":56},{"x":160,"y":64},{"x":160,"y":72},{"x":160,"y":80},{"x":160,"y":88},{"x":160,"y":96},{"x":170,"y":24},{"x":170,"y":32},{"x":170,"y":40},{"x":170,"y":48},{"x":170,"y":56},{"x":170,"y":64},{"x":170,"y":72},{"x":170,"y":80},{"x":170,"y":88},{"x":180,"y":24},{"x":180,"y":32},{"x":180,"y":40},{"x":180,"y":48},{"x":180,"y":56},{"x":180,"y":64},{"x":180,"y":72},{"x":180,"y":80},{"x":190,"y":24},{"x":190,"y":32},{"x":190,"y":40},{"x":190,"y":48},{"x":190,"y":56},{"x":190,"y":64},{"x":190,"y":72},{"x":200,"y":24},{"x":200,"y":32},{"x":200,"y":40},{"x":200,"y":48},{"x":200,"y":56},{"x":200,"y":64},{"x":210,"y":24},{"x":210,"y":32},{"x":210,"y":40},{"x":210,"y":48},{"x":210,"y":56},{"x":220,"y":24},{"x":220,"y":32},{"x":220,"y":40},{"x":220,"y":48}];
// // var youzhong = [{"x":140,"y":120},{"x":140,"y":128},{"x":150,"y":112},{"x":150,"y":120},{"x":150,"y":128},{"x":150,"y":136},{"x":160,"y":104},{"x":160,"y":112},{"x":160,"y":120},{"x":160,"y":128},{"x":160,"y":136},{"x":160,"y":144},{"x":170,"y":96},{"x":170,"y":104},{"x":170,"y":112},{"x":170,"y":120},{"x":170,"y":128},{"x":170,"y":136},{"x":170,"y":144},{"x":180,"y":88},{"x":180,"y":96},{"x":180,"y":104},{"x":180,"y":112},{"x":180,"y":120},{"x":180,"y":128},{"x":180,"y":136},{"x":180,"y":144},{"x":180,"y":152},{"x":190,"y":80},{"x":190,"y":88},{"x":190,"y":96},{"x":190,"y":104},{"x":190,"y":112},{"x":190,"y":120},{"x":190,"y":128},{"x":190,"y":136},{"x":190,"y":144},{"x":190,"y":152},{"x":190,"y":160},{"x":200,"y":72},{"x":200,"y":80},{"x":200,"y":88},{"x":200,"y":96},{"x":200,"y":104},{"x":200,"y":112},{"x":200,"y":120},{"x":200,"y":128},{"x":200,"y":136},{"x":200,"y":144},{"x":200,"y":152},{"x":200,"y":160},{"x":200,"y":168},{"x":210,"y":64},{"x":210,"y":72},{"x":210,"y":80},{"x":210,"y":88},{"x":210,"y":96},{"x":210,"y":104},{"x":210,"y":112},{"x":210,"y":120},{"x":210,"y":128},{"x":210,"y":136},{"x":210,"y":144},{"x":210,"y":152},{"x":210,"y":160},{"x":210,"y":168},{"x":220,"y":56},{"x":220,"y":64},{"x":220,"y":72},{"x":220,"y":80},{"x":220,"y":88},{"x":220,"y":96},{"x":220,"y":104},{"x":220,"y":112},{"x":220,"y":120},{"x":220,"y":128},{"x":220,"y":136},{"x":220,"y":144},{"x":220,"y":152},{"x":220,"y":160},{"x":220,"y":168},{"x":220,"y":176}];
// // var youxia = [{"x":130,"y":128},{"x":130,"y":136},{"x":130,"y":144},{"x":130,"y":152},{"x":130,"y":160},{"x":130,"y":168},{"x":130,"y":176},{"x":130,"y":184},{"x":130,"y":192},{"x":130,"y":200},{"x":130,"y":208},{"x":130,"y":216},{"x":140,"y":136},{"x":140,"y":144},{"x":140,"y":152},{"x":140,"y":160},{"x":140,"y":168},{"x":140,"y":176},{"x":140,"y":184},{"x":140,"y":192},{"x":140,"y":200},{"x":140,"y":208},{"x":140,"y":216},{"x":150,"y":144},{"x":150,"y":152},{"x":150,"y":160},{"x":150,"y":168},{"x":150,"y":176},{"x":150,"y":184},{"x":150,"y":192},{"x":150,"y":200},{"x":150,"y":208},{"x":150,"y":216},{"x":160,"y":152},{"x":160,"y":160},{"x":160,"y":168},{"x":160,"y":176},{"x":160,"y":184},{"x":160,"y":192},{"x":160,"y":200},{"x":160,"y":208},{"x":160,"y":216},{"x":170,"y":152},{"x":170,"y":160},{"x":170,"y":168},{"x":170,"y":176},{"x":170,"y":184},{"x":170,"y":192},{"x":170,"y":200},{"x":170,"y":208},{"x":170,"y":216},{"x":180,"y":160},{"x":180,"y":168},{"x":180,"y":176},{"x":180,"y":184},{"x":180,"y":192},{"x":180,"y":200},{"x":180,"y":208},{"x":180,"y":216},{"x":190,"y":168},{"x":190,"y":176},{"x":190,"y":184},{"x":190,"y":192},{"x":190,"y":200},{"x":190,"y":208},{"x":190,"y":216},{"x":200,"y":176},{"x":200,"y":184},{"x":200,"y":192},{"x":200,"y":200},{"x":200,"y":208},{"x":200,"y":216},{"x":210,"y":176},{"x":210,"y":184},{"x":210,"y":192},{"x":210,"y":200},{"x":210,"y":208},{"x":210,"y":216},{"x":220,"y":184},{"x":220,"y":192},{"x":220,"y":200},{"x":220,"y":208}];
// // var zuozhong =  [{"x":30,"y":56},{"x":30,"y":64},{"x":30,"y":72},{"x":30,"y":80},{"x":30,"y":88},{"x":30,"y":96},{"x":30,"y":104},{"x":30,"y":112},{"x":30,"y":120},{"x":30,"y":128},{"x":30,"y":136},{"x":30,"y":144},{"x":30,"y":152},{"x":30,"y":160},{"x":30,"y":168},{"x":30,"y":176},{"x":40,"y":64},{"x":40,"y":72},{"x":40,"y":80},{"x":40,"y":88},{"x":40,"y":96},{"x":40,"y":104},{"x":40,"y":112},{"x":40,"y":120},{"x":40,"y":128},{"x":40,"y":136},{"x":40,"y":144},{"x":40,"y":152},{"x":40,"y":160},{"x":40,"y":168},{"x":40,"y":176},{"x":50,"y":72},{"x":50,"y":80},{"x":50,"y":88},{"x":50,"y":96},{"x":50,"y":104},{"x":50,"y":112},{"x":50,"y":120},{"x":50,"y":128},{"x":50,"y":136},{"x":50,"y":144},{"x":50,"y":152},{"x":50,"y":160},{"x":50,"y":168},{"x":60,"y":80},{"x":60,"y":88},{"x":60,"y":96},{"x":60,"y":104},{"x":60,"y":112},{"x":60,"y":120},{"x":60,"y":128},{"x":60,"y":136},{"x":60,"y":144},{"x":60,"y":152},{"x":60,"y":160},{"x":70,"y":88},{"x":70,"y":96},{"x":70,"y":104},{"x":70,"y":112},{"x":70,"y":120},{"x":70,"y":128},{"x":70,"y":136},{"x":70,"y":144},{"x":70,"y":152},{"x":80,"y":96},{"x":80,"y":104},{"x":80,"y":112},{"x":80,"y":120},{"x":80,"y":128},{"x":80,"y":136},{"x":80,"y":144},{"x":80,"y":152},{"x":90,"y":104},{"x":90,"y":112},{"x":90,"y":120},{"x":90,"y":128},{"x":90,"y":136},{"x":90,"y":144},{"x":100,"y":112},{"x":100,"y":120},{"x":100,"y":128},{"x":100,"y":136},{"x":110,"y":120},{"x":110,"y":128},{"x":120,"y":120},{"x":120,"y":128}];
// // var zuoxia = [{"x":30,"y":184},{"x":30,"y":192},{"x":30,"y":200},{"x":30,"y":208},{"x":40,"y":184},{"x":40,"y":192},{"x":40,"y":200},{"x":40,"y":208},{"x":50,"y":176},{"x":50,"y":184},{"x":50,"y":192},{"x":50,"y":200},{"x":50,"y":208},{"x":50,"y":216},{"x":60,"y":168},{"x":60,"y":176},{"x":60,"y":184},{"x":60,"y":192},{"x":60,"y":200},{"x":60,"y":208},{"x":60,"y":216},{"x":70,"y":160},{"x":70,"y":168},{"x":70,"y":176},{"x":70,"y":184},{"x":70,"y":192},{"x":70,"y":200},{"x":70,"y":208},{"x":70,"y":216},{"x":80,"y":160},{"x":80,"y":168},{"x":80,"y":176},{"x":80,"y":184},{"x":80,"y":192},{"x":80,"y":200},{"x":80,"y":208},{"x":80,"y":216},{"x":90,"y":152},{"x":90,"y":160},{"x":90,"y":168},{"x":90,"y":176},{"x":90,"y":184},{"x":90,"y":192},{"x":90,"y":200},{"x":90,"y":208},{"x":90,"y":216},{"x":100,"y":144},{"x":100,"y":152},{"x":100,"y":160},{"x":100,"y":168},{"x":100,"y":176},{"x":100,"y":184},{"x":100,"y":192},{"x":100,"y":200},{"x":100,"y":208},{"x":100,"y":216},{"x":110,"y":136},{"x":110,"y":144},{"x":110,"y":152},{"x":110,"y":160},{"x":110,"y":168},{"x":110,"y":176},{"x":110,"y":184},{"x":110,"y":192},{"x":110,"y":200},{"x":110,"y":208},{"x":110,"y":216},{"x":120,"y":136},{"x":120,"y":144},{"x":120,"y":152},{"x":120,"y":160},{"x":120,"y":168},{"x":120,"y":176},{"x":120,"y":184},{"x":120,"y":192},{"x":120,"y":200},{"x":120,"y":208},{"x":120,"y":216}];

// // // 默认方法
// // function log(){
// //     log(arguments)
// // }
// // // 检查无障碍服务是否已经启用，如果没有启用则跳转到无障碍服务启用界面，并等待无障碍服务启动；当无障碍服务启动后脚本会继续运行。
// // auto.waitFor()
// // // 打开app
// // app.launchPackage(gamePackageName);
// // log("游戏启动中，请稍等...")
// // sleep(3000)
// // //截图权限自动化安卓版本高于Android 9
// // if (device.sdkInt > 27) {
// //     //等待截屏权限申请并同意
// //     threads.start(function () {
// //         if (device.brand == "HUAWEI") {
// //             packageName('com.android.systemui').text('允许').waitFor();
// //             sleep(500)
// //             text('允许').click();
// //         } else {
// //             packageName('com.android.systemui').text('立即开始').waitFor();
// //             sleep(500)
// //             text('立即开始').click();
// //         }
// //     });
// // }
// // //申请截屏权限
// // if (!requestScreenCapture(true)) {
// //     toastLog("请求截图失败");
// //     exit()
// // }


// // // 查看世界地图
// // function seeShijieditu(x,y) {
// //     let thisImgs = images.read("./res/世界地图按钮.png");
// //     thisImgs = images.scale(thisImgs, picJizhun, picJizhunHeight)
// //     let p = findImage(captureScreen(), thisImgs);
// //     thisImgs.recycle();
// //     if (p) {
// //         log('打开世界地图')
// //         sleep(yanchi)
// //         click(p.x, p.y)
// //         sleep(yanchi1)
// //     }

// //     // 如果是第一次则配置地图 700*600
// //     if (true) {
// //         log('第一次配置小地图参数')
// //         sleep(yanchi1)
// //         let thisImgs1 = images.read("./res/小地图.png");
// //         thisImgs1 = images.scale(thisImgs1, picJizhun, picJizhunHeight)
// //         let p1 = findImage(captureScreen(), thisImgs1, { threshold: 0.8 });
// //         thisImgs1.recycle();
// //         if (p1) {
// //             // 以后小地图把p1点当作坐标 0,0
// //             log(p1)
// //             // 700*600 成上基准值   32 16
// //             // 21个屏幕 37个高  16 8   254 250
// //             // 700/254=2.755905511811024 600/250=2.4
// //             sleep(yanchi)
// //             goXyFunc(x,y)
// //             // goXyFunc(117,44)

// //             // goXyFunc(214,163)
// //             // goXyFunc(198,153)
// //         }
// //     }
// // }


// // function goXyFunc(x, y) {
// //     log('前往采集点：', x, y)
// //     let zhia = parseInt(x/50)+1;
// //     if (x < 127) {
// //         zhia = zhia - 1;
// //     }
// //     let xx = 440 + ((x + zhia) * 2.755905511811024)
// //     let yy = 184 + (y * 2.4)
// //     sleep(yanchi)
// //     log(xx, yy)
// //     click(xx, yy)
// //     sleep(yanchi2)
// // }


// // // 前往指定坐标 483就是16 进阶2.82 需要算法支持各种分辨率
// // function goXyFunc1(x, y) {
// //     log('前往采集点：', x, y)
// //     let xx = Math.round(483 + (x - 16) * 2.82)
// //     let yy = Math.round(484 + (y - 125) * 2.44)
// //     sleep(yanchi)
// //     log(xx, yy)
// //     click(xx, yy)
// //     sleep(yanchi2)
// // }

// // for (let index = 0; index < zuoshang.length; index++) {
// //     let element = zuoshang[index];
// //     log(element)
// //     sleep(3000)
// //     seeShijieditu(element.x,element.y)
// // }
